home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / bluebook.zip / FLOATPT.DOC < prev    next >
Text File  |  1986-05-14  |  19KB  |  434 lines

  1. FLOATPT.DOC -- Floating Point Conversion Procedures
  2. ===================================================
  3.  
  4.   From `BLUEBOOK of ASSEMBLY ROUTINES for the IBM PC & XT'
  5.         by Christopher L. Morgan
  6.         Copyright (C) 1984 by The Waite Group, Inc.
  7.  
  8.   Purpose: These procedures perform input, conversion, and output on 
  9.     floating point numbers.
  10.  
  11.    Contents:
  12.    ---------
  13.    BIN802DEC    --  Convert from 80-bit binary to decimal digits
  14.    DECDOUBLE    --  Double a temporary decimal floating point number
  15.    DECHALF    --  Halve a temporary decimal floating point number
  16.    DECNORM    --  Normalize temporary decimal floating point
  17.    DFP2SFP    --  Convert from double to single precision floating point
  18.    FIX        --  Convert from floating point to 16-bit integer
  19.    FLOAT    --  Convert from 16-bit integer to floating point
  20.    FPIN        --  Convert from external to internal floating point
  21.    FPINDIGIT    --  Convert from decimal digit to temporary floating point
  22.    FPOUT    --  Convert from internal to external floating point
  23.    FPTDIV    --  Divide temporary floating point by 10
  24.    FPTMUL    --  Multiply temporary floating point by 10
  25.    FPTNORM    --  Normalize temporary floating point
  26.    SFP2DFP    --  Convert from single to double precision floating point
  27.    SFP2TFP    --  Convert from single precision to temporary floating point
  28.    SGNDEC16IN    --  Convert from ASCII signed decimal to binary
  29.    TDECSHOW    --  Display floating point
  30.    TFP2SFP    --  Convert from temporary floating point to single precision
  31. _____________________________________________________________________________
  32.  
  33.   Overview
  34.  
  35. __________________________ FLOATING POINT ROUTINES __________________________
  36. -----------------------------------------------------------------------------
  37. Conversion from 80-bit binary to decimal digits
  38. BIN802DEC
  39.  
  40.   Function: This routine converts an 80-bit binary integer to a decimal string.
  41.  
  42.   Input: Upon entry, SI points to an 80-bit binary integer to be used as input
  43.     and DI points to a 25-digit decimal string to be used as output.
  44.  
  45.   Output: Upon exit, a 25-digit decimal string is where DI pointed upon entry.
  46.     DI still points there upon exit.
  47.  
  48.   Registers used: AX, BX, CX, DX, and SI are modified; DI points to output.
  49.  
  50.   Segments referenced: The data segment contains storage for the 80-bit binary
  51.     number (10 bytes) and the 25-digit decimal number (25 bytes).
  52.  
  53.   Note: This is a near procedure needed by FPOUT.
  54. -----------------------------------------------------------------------------
  55. Double a temporary decimal floating point number
  56. DECDOUBLE
  57.  
  58.   Function: This routine multiplies a temporary decimal floating point
  59.     number by two.
  60.  
  61.   Input: Upon entry, DS:DI points to a temporary decimal floating point number.
  62.  
  63.   Output: Upon exit, the number has been doubled.
  64.  
  65.   Registers used: AX,CX, & DX are modified.
  66.  
  67.   Segments referenced: The data segment contains storage for the temporary
  68.     decimal floating point number.    
  69.  
  70.   Note: This is a near procedure needed by FPOUT.
  71.  
  72. -----------------------------------------------------------------------------
  73. Half a temporary decimal floating point number
  74. DECHALF
  75.  
  76.   Function: This routine divides a temporary decimal floating number by two.
  77.  
  78.   Input: Upon entry, DI points to a temporary decimal floating point number.
  79.  
  80.   Output: Upon exit, the number has been divided by two. The result is not
  81.     normalized.
  82.  
  83.   Registers used: AX, CX, and DI are modified.
  84.  
  85.   Segments referenced: The data segment contains a temporary decimal floating
  86.     point number.
  87.  
  88.   Note: This is a near procedure needed by FPOUT.
  89. -----------------------------------------------------------------------------
  90. Normalize a temporary decimal floating point number
  91. DECNORM
  92.  
  93.   Function: This routine normalizes a temporary decimal floating number.
  94.  
  95.   Input: Upon entry, DI points to a temporary decimal floating point number.
  96.  
  97.   Output: Upon exit, the number is normalized.
  98.  
  99.   Registers used: AX, CX, and DI are modified.
  100.  
  101.   Segments referenced: The data segment contains a temporary decimal floating
  102.     point number.
  103.  
  104.   Note: Equates are used to shorten address fields. This is a near procedure
  105.      needed by FPOUT.
  106. -----------------------------------------------------------------------------
  107. Convert from double to single precision floating point
  108. DFP2SFP
  109.  
  110.   Function: This routine converts an internal double precision binary floating
  111.     point number to an internal single precision floating point number.
  112.  
  113.   Input: Upon entry, a double precision binary floating point number is in
  114.     DFPBUFF. The double precision floating point number has a 40-bit binary
  115.     mantissa, a sign bit, and an 8-bit exponent biased by 128.    
  116.  
  117.   Output: Upon exit, a single precision binary floating point number is in
  118.     SFPBUFF. The single precision floating point number has a 24-bit binary
  119.     mantissa, a sign bit, and an 8-bit exponent biased by 128.
  120.  
  121.   Registers used: Unmodified; AX is saved and restored.
  122.  
  123.   Segments referenced: The data segment contains storage for the variables,
  124.     SFPBUFF and DFPBUFF.
  125.  
  126.   Note: Equates are used to shorten address fields.
  127.  
  128. -----------------------------------------------------------------------------
  129. Convert from floating point to 16-bit integer
  130. FIX
  131.  
  132.   Function: This routine converts from internal single precision binary
  133.     floating point to internal 16-bit signed two's complement integer.
  134.  
  135.   Input: Upon entry, a single precision binary floating point is in SFPBUFF.
  136.     The single precision floating point number has a 24-bit binary mantissa, 
  137.     a sign bit, and an 8-bit exponent biased by 128.
  138.  
  139.   Output: Upon exit, a 16-bit signed two's complement binary number is in DX.
  140.  
  141.   Registers used: DX is used for output; CX,and AX are saved and then restored.
  142.  
  143.   Segments referenced: The data segment contains storage for SFPBUFF.
  144.  
  145.   Note: Equates are used to shorten address fields.
  146. -----------------------------------------------------------------------------
  147. Convert from 16-bit integer to floating point
  148. FLOAT
  149.  
  150.   Function: This routine converts an unsigned 16-bit binary number to a
  151.     single precision binary floating point number.
  152.  
  153.   Input: Upon entry, DX contains an unsigned 16-bit binary number.
  154.  
  155.   Output: Upon exit, SFPBUFF contains a single precision floating point
  156.     number. The single precision floating point number has a 24-bit binary
  157.     mantissa, a sign bit, and an 8-bit exponent biased by 128.
  158.  
  159.   Registers used: Unmodified; DX is used for input; DX, CX, & AX are saved
  160.     and then restored.
  161.  
  162.   Segments referenced: The data segment contains storage for the variable, 
  163.     SFPBUFF and the message, INTERNAL.
  164.  
  165.   Routines called: STDMSG_OUT,HEX16OUT,STD_SPACE (all for debugging).
  166.  
  167.   Note: Equates are used to shorten address fields.
  168. -----------------------------------------------------------------------------
  169. Convert from external to internal floating point
  170. FPIN
  171.  
  172.   Function: This routine accepts an ASCII decimal floating point number from
  173.     a standard input device and converts it to internal binary floating point.
  174.  
  175.   Input: The characters of the floating point number are received in ASCII
  176.     through a call to a standard input routine. The decimal floating point
  177.     number has an optional sign, followed by decimal digits of the mantissa
  178.     with one embedded decimal point. Following the mantissa is an optional
  179.     exponent starting with the letter, 'E', then an optional sign, then a
  180.     decimal number. It is possible to get erroneous results if the number is
  181.     too large or small to be stored as a single precision binary floating 
  182.     point number.
  183.  
  184.   Output: Upon exit a single precision binary floating point number is in
  185.     SFPBUFF. The single precision floating point number has a 24-bit binary
  186.     mantissa, a sign bit, and an 8-bit exponent biased by 128.
  187.  
  188.   Registers used: Unmodified; DI, SI, DX, CX, & AX are saved and restored.
  189.  
  190.   Segments referenced: The data segment contains the variables, FPTEMP1,
  191.     FPTEMP2, and SFPBUFF.
  192.  
  193.   Routines called: STD_IN, FPINDIGIT, FPMUL, FPTDIV, and FPTNORM.